import { sendRequest } from "@/utils/http/interceptors";
import { handleFactory, handleTypeEnum } from "../handleFactory";
import { interceptorResponseFactory } from "@/utils/http/interceptors";

/**
 * 响应拦截器处理
 *
 * @param {Object} _ Axios
 * @param {Object} config Axios Config
 * @returns {Object} Axios Config
 * @returns {Promise} Error
 */
export function interceptorHandle(http, res) {
  sendRequest.complete();
  return interceptorResponseFactory.execute(http, res);
}

/**
 * 响应拦截器错误处理
 *
 * @param {Object} _ Axios
 * @param {Object} error Axios Error
 * @returns {Promise} Axios Error
 */
export function interceptorExceptionHandle(http, error) {
  sendRequest.complete();
  return handleFactory.execute(handleTypeEnum.ERROR, http, error);
}
